public class Test2 {
    public static void main(String[] args) {
        String s="leetcode";
        int result=firstUniqChar(s);
        System.out.println(result);
    }
    public static int firstUniqChar(String s) {
        int[] count = new int[256];
        for (int i = 0; i <s.length(); i++) {
            count[s.charAt(i)]++;
        }
        for (int i = 0; i <s.length() ; i++) {
            if(count[s.charAt(i)]==1){
                return i;
            }
        }return -1;
    }
}
